package com.lr.server.demo1;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Date;

/*
 * 创建服务器并启动
 */
public class Server4 {
	
	private ServerSocket server;
	
	public static void main(String[] args) {
		Server4 server = new Server4();
		server.start();
		
	}
	
	public void start(){
		try {
			server = new ServerSocket(8888);
			this.recieve();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public void recieve(){
		
		try {
			Socket socket = server.accept();
			Request request = new Request(socket);
			Response response = new Response(socket);
			Servlet servlet = new Servlet();
			servlet.service(request,response);
			
			//处理多线程问题
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public void stop(){
		
	}

}
